package ast;

import compiler.OutputFormatter;

public class VarDec extends Statement {
	
	private Variable variable;
	
	public VarDec(Variable variable) {
		this.variable = variable;
	}
	
	@Override
	public void genC(OutputFormatter of) {
		Type type = variable.getType();
		
        type.genC(of);
        of.space();
        of.output(variable.getName());
        if (type == Type.INT)
            of.output(" = 0");
        else if (type == Type.STR)
            of.output(" = string_new()");
        super.genC(of);
	}
}
